import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/merchant_entity.dart';

MerchantEntity $MerchantEntityFromJson(Map<String, dynamic> json) {
  final MerchantEntity merchantEntity = MerchantEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    merchantEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    merchantEntity.msg = msg;
  }
  final List<MerchantData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<MerchantData>(e) as MerchantData).toList();
  if (data != null) {
    merchantEntity.data = data;
  }
  return merchantEntity;
}

Map<String, dynamic> $MerchantEntityToJson(MerchantEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension MerchantEntityExtension on MerchantEntity {
  MerchantEntity copyWith({
    int? code,
    String? msg,
    List<MerchantData>? data,
  }) {
    return MerchantEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

MerchantData $MerchantDataFromJson(Map<String, dynamic> json) {
  final MerchantData merchantData = MerchantData();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    merchantData.id = id;
  }
  final String? isQq = jsonConvert.convert<String>(json['is_qq']);
  if (isQq != null) {
    merchantData.isQq = isQq;
  }
  final String? qqNum = jsonConvert.convert<String>(json['qq_num']);
  if (qqNum != null) {
    merchantData.qqNum = qqNum;
  }
  final String? qqsNum = jsonConvert.convert<String>(json['qqs_num']);
  if (qqsNum != null) {
    merchantData.qqsNum = qqsNum;
  }
  final String? wxNum = jsonConvert.convert<String>(json['wx_num']);
  if (wxNum != null) {
    merchantData.wxNum = wxNum;
  }
  final String? isQrcode = jsonConvert.convert<String>(json['is_qrCode']);
  if (isQrcode != null) {
    merchantData.isQrcode = isQrcode;
  }
  final String? codeUrl = jsonConvert.convert<String>(json['code_url']);
  if (codeUrl != null) {
    merchantData.codeUrl = codeUrl;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    merchantData.name = name;
  }
  return merchantData;
}

Map<String, dynamic> $MerchantDataToJson(MerchantData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['is_qq'] = entity.isQq;
  data['qq_num'] = entity.qqNum;
  data['qqs_num'] = entity.qqsNum;
  data['wx_num'] = entity.wxNum;
  data['is_qrCode'] = entity.isQrcode;
  data['code_url'] = entity.codeUrl;
  data['name'] = entity.name;
  return data;
}

extension MerchantDataExtension on MerchantData {
  MerchantData copyWith({
    String? id,
    String? isQq,
    String? qqNum,
    String? qqsNum,
    String? wxNum,
    String? isQrcode,
    String? codeUrl,
    String? name,
  }) {
    return MerchantData()
      ..id = id ?? this.id
      ..isQq = isQq ?? this.isQq
      ..qqNum = qqNum ?? this.qqNum
      ..qqsNum = qqsNum ?? this.qqsNum
      ..wxNum = wxNum ?? this.wxNum
      ..isQrcode = isQrcode ?? this.isQrcode
      ..codeUrl = codeUrl ?? this.codeUrl
      ..name = name ?? this.name;
  }
}